#include <stdio.h>
#include <string.h>
#include <math.h>

int my_atoi(const char* str)
{
    const char *cur = str;
    int flag = 0;
    int count = 0;
    while(*cur)
    {
        if(*cur >= '0' && *cur <= '9')
        {
            count++;
            cur++;
        }else if(*cur == '-' && flag == 0)
        {
            flag = 1;
            cur++;
        }else{
            break;
        }        
    }
    cur--;
    int value = count;
    int sum = 0;
    while(count) //count = 6;
    {
        int tmp = *cur;
        tmp *= pow(10, value-count);
        sum += tmp;
        count--;
        cur--;
    }
    if(flag == 1){
        sum = -sum;
    }
    return sum;

}



int main()
{
    char arr[20] = "hhhdasdad";
    const char *s = "-119231jsajja182831";
    int a = 0;
    a = atoi(s);
    printf("%d\n", a);
    return 0;
}